﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Deloitte;
using System.ComponentModel;

public static class Extensions
{
    public static List<T> RemoveDuplicates<T>(this List<T> input)
    {
        Dictionary<T, int> uniqueStore = new Dictionary<T, int>();
        List<T> finalList = new List<T>();
        foreach (T currValue in input)
        {

            if (!uniqueStore.ContainsKey(currValue))
            {

                uniqueStore.Add(currValue, 0);
                finalList.Add(currValue);
            }
        }
        return finalList;
    }
    public static TrackChangesBindingList<T> ToTrackChangesBindingList<T>(this List<T> input) where T : ITrackChange, INotifyPropertyChanged
    {
        TrackChangesBindingList<T> trackChangesList = new TrackChangesBindingList<T>();
        foreach (T currValue in input)
        {
            trackChangesList.Add(currValue);
        }
        return trackChangesList;
    }
    public static BindingList<T> ToBindingList<T>(this List<T> input) 
    {
        BindingList<T> list = new BindingList<T>();
        foreach (T currValue in input)
        {
            list.Add(currValue);
        }
        return list;
    }
}